#include "hashTable.h"
#include "linklist.h"
/*构造函数*/
hashTable::hashTable()
{
    /*将m_data里面的每个slot都存放链表节点*/
}
/*析构函数*/
hashTable::~hashTable()
{
}

/*哈希函数*/
int hashTable::myHashFunc(int key)
{
    int slot = key % m_capacity; // 0-14
    return slot;
}

/*插入数据*/
void hashTable::insertData(int key, char *value)
{
    int slot = myHashFunc(key);
    /*哈希表结点*/
    HashNode *node = new HashNode;
    // node.key = key;
    int length = strlen(value);
    node.value = new char[length + 1];
    memset(node.value, 0, sizeof(char) * (length + 1));
    strcpy(node.value, value);
    m_data[slot].linkListTailInsert((void *)&node);
}

/*删除数据*/
void hashTable::deletData(int key)
{
    int slot = myHashFunc(key);
    LinkList &list = m_data[slot];
    list.linkListDeleteByKey(key); // 假设你有这样的函数来删除指定key的节点
}

/*判断指定的key是否存在*/
bool hashTable::isContained(int key)
{
    int slot = myHashFunc(key);
    LinkList tmpList = m_data[slot];
    int length = tmpList.getsize();
    for (int idx = 0; idx < length; idx++)
    {
        tmpList.linkListAppointPosDelete
    }
}
